<template lang="pug">
.img-wrap
  img.ui.image.img(v-bind:src="src")
  .btns
    .ui.button(@click="$els.input.click()") 上传
    upload-input(v-el:input, v-bind:value.sync="value")
    .ui.button(@click="remove") 删除
</template>

<script>
import qiniu from '../../helper/qiniu'
import UploadInput from './input'

export default {
  name: 'uploadImg',
  components: {
    UploadInput,
  },
  props: ['src'],
  data () {
    return {
      file: null,
      value: null,
    }
  },
  methods: {
    remove () {
      swalConfirm('确定要删除?', ()=>{
        this.src = null
      }, true)
    }
  },
  watch: {
    value (val, old) {
      this.src = val
    },
  },
}
</script>

<style lang="sass" scoped>
.btns
  margin: 10px 0 0 0
  display: none
.img-wrap:hover
  .img
    display: none
  .btns
    display: block
</style>
